#!/usr/bin/env python
# _*_coding:utf-8 _*_
__author__ = "Gao"
'''加载位图'''

import random,math,pygame
import sys

from pygame.locals import *

pygame.init()

screen = pygame.display.set_mode((800,600))

space = pygame.image.load('space.jpg').convert()    # 宇宙背景图

planet = pygame.image.load('planet.png').convert_alpha()    # 月球
planet_width,planet_height = planet.get_size()    # 获取月球的宽度和高度

ship = pygame.image.load('ship.tga').convert_alpha()    # 飞船
ship_width,ship_height = ship.get_size()    # 获取飞船的宽度和高度
# ship = pygame.transform.scale(ship,(ship_width//2,ship_height//2))    # 缩放位图
ship = pygame.transform.smoothscale(ship,(ship_width//2,ship_height//2))   # 平滑的方式缩放位图，效果更好

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            sys.exit()
    keys = pygame.key.get_pressed()
    if keys[K_ESCAPE]:
        sys.exit()

    screen.blit(space,(0,0))
    screen.blit(planet,(400-planet_width/2,300-planet_height/2))
    screen.blit(ship, (50, 50))
    pygame.display.update()